#!/bin/bash
set -e
ulimit -n 1000000

DEPLOY_DIR={{ deploy_dir }}
cd "${DEPLOY_DIR}" || exit 1

{% set my_ip = hostvars[inventory_hostname].ansible_host | default(hostvars[inventory_hostname].inventory_hostname) -%}

exec > >(tee -i -a "{{ prometheus_log_dir }}/{{ prometheus_log_filename }}")
exec 2>&1

exec bin/prometheus \
    --config.file="{{ deploy_dir }}/conf/prometheus.yml" \
    --web.listen-address=":{{ prometheus_port }}" \
    --web.external-url="http://{{ my_ip }}:{{ prometheus_port }}/" \
    --web.enable-admin-api \
    --log.level="{{ prometheus_log_level }}" \
    --storage.tsdb.path="{{ prometheus_data_dir }}" \
    --storage.tsdb.retention="{{ prometheus_storage_retention }}"

